
<div class="layui-form seller-form"  action="" >
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">商品名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="title" style="width:200px;" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-inline">
            <button class="layui-btn layui-btn-sm" lay-submit lay-filter="goods-search">查询</button>
        </div>
    </div>
</div>

<table id="goodsTable" lay-filter="goodsTable"></table>

<script>
    layui.use(['form', 'laydate','table'], function(){
        var layer = layui.layer, table = layui.table,form = layui.form,date = layui.laydate;
        table.render({
            elem: '#goodsTable',
            height: '330',
            cellMinWidth: '80',
            page: 'true',
            limit:'20',
            url: "{:url('Goods/index')}?_ajax=1",
            id:'goodsTable',
            cols: [[
                {type: 'numbers'},
                {field:'image', width:100,title:'缩略图', align: 'center',templet: function(data){
                    return '<a href="javascript:void(0);" onclick=viewImage("'+data.image+'")><image style="max-width:30px;max-height:30px;" src="'+data.image+'"/></a>';
                }},
                {field:'name', width:370,title:'名称', align: 'center'},
                {field:'stock', width:80,title:'库存', align: 'center'},
                {fixed: 'right', width:100, title:'操作',align:'center', toolbar:'#goodsBar'}
            ]]
        });
        form.on('submit(goods-search)', function(data){
            layui.table.reload('goodsTable', {
                where: data.field
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>

<script type="text/html" id="goodsBar">
    <a class="layui-btn layui-btn-xs" lay-event="selectGoods">选择</a>
</script>
